<!--
 * @Author: 刘晟勇
 * @Date: 2021-10-23 09:48:29
 * @LastEditTime: 2021-10-23 17:10:02
 * @Description: qq台历服务器
-->

<template>
  <div>
  </div>
</template>

<script>
// 导入混入api方法
import { getQQInfo, loginQQ } from "@/api/login"

export default {
  name: 'Proxy',
  created() {
    if (this.$QC.Login.check()) {
      this.$QC.Login.getMe((openId, accessToken) => {
        const params = {
          openid: openId,
          access_token: accessToken,
          oauth_consumer_key: '101850878'
        }
        getQQInfo(params, (data) => {
          if (data.status === 0) {
            const params = {
              openid: openId,
              username: data.data.nickname
            }
            loginQQ(params, (data) => {
              this.$store.commit('setLoginStatue', {token: data.token, isLogin: true})
              this.$store.dispatch('getInfo')
              this.$router.replace('/user')
            })
          }
        })
      })
    } else {
      console.log('登录失败')
    }
  }
}
</script>

<style>

</style>